package lion.framework.core.web.request.multi;

import java.util.Enumeration;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;

/**
 * @author lion
 * @email hl_0074@sina.com
 * @date 2014年5月27日
 */
public class MultiRequestWrapper extends HttpServletRequestWrapper {

	private UploadRequestParser requestParser;

	public MultiRequestWrapper(HttpServletRequest request) throws FileUploadException {

		super(request);

		try {
			this.requestParser = new UploadRequestParser(request);
		} catch (FileUploadException e) {
			throw e;
		}
	}

	@Override
	public String getParameter(String name) {

		return requestParser.getParameter(name);
	}

	@Override
	public Enumeration<String> getParameterNames() {

		return requestParser.getParameterNames();
	}

	@Override
	public String[] getParameterValues(String name) {

		return this.requestParser.getParameterValues(name);
	}

	@Override
	public Map<String, String[]> getParameterMap() {

		return this.requestParser.getParameterValuesMap();
	}

	public void cleanUp() {

		this.requestParser.cleanUp();
	}

	public List<FileItem> getUploadFileItems() {

		return this.requestParser.getUploadFileItems();
	}

	public FileItem[] getUploadFileItems(String name) {

		return this.requestParser.getFileItems(name);
	}

	public FileItem getUploadFileItem(String name) {

		return this.requestParser.getFileItem(name);
	}

}
